package com.my.study.designPatterns.commandPattern;

public class RemoteControl {

    private Command [] onCommands;


    private Command [] offCommands;


    private Command lastCommand;


    public RemoteControl(Command[] onCommands, Command[] offCommands) {
        this.onCommands = onCommands;
        this.offCommands = offCommands;
    }


    public void leftBtnWasPushed(int i){
        onCommands[i].execute();
        lastCommand = onCommands[i];
    }



    public void rightBtnWasPushed(int i){
        offCommands[i].execute();
        lastCommand = offCommands[i];
    }


    public void undoBtnWasPushed(){
        lastCommand.undo();
    }

}
